package main

import (
	_ "GinTemplate/docs"
	"GinTemplate/internal/configs"
	"GinTemplate/internal/router"
	"fmt"
	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
	"net/http"
)

// DC Label Server
// @title			DC Label API
// @version         1.0
// @description     This is a simple dc label server.
// @contact.name	zzq
// @contact.email	zhangzhanqi@iie.ac.cn
// @license.name	Apache 2.0
// @license.url		http://www.apache.org/licenses/LICENSE-2.0.html
func main() {
	r := gin.Default()

	r.GET("/ping", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "pong",
		})
	})

	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
	r.GET("/docs", func(c *gin.Context) {
		c.Redirect(http.StatusMovedPermanently, "/swagger/index.html")
	})

	router.APIRegister(r)
	r.Run(fmt.Sprintf("0.0.0.0:%d", configs.Config.Port)) // 监听并在 0.0.0.0:8080 上启动服务
}
